package com.fancy.learncenter.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.fancy.learncenter.adapter.base.CommonRecycleViewAdapter;
import com.fancy.learncenter.adapter.base.CustomViewHold;
import com.fancy.learncenter.bean.NearbyDataBean;
import com.superservice.lya.R;

import java.util.ArrayList;

import io.rong.imkit.RongIM;

/**
 * Created by hyy on 2018/1/27.
 * Explain activity as
 */

public class ToothFJAdapter extends CommonRecycleViewAdapter<NearbyDataBean> {

    public ToothFJAdapter(Context mContext, ArrayList<NearbyDataBean> itemDatas) {
        super(mContext, R.layout.fragment_tooth_nearby_item, itemDatas);
    }

    @Override
    public void bindView(CustomViewHold customViewHold, final NearbyDataBean item, int position) {

        SimpleDraweeView simpleDraweeView = customViewHold.getView(R.id.simpleDraweeView);
        simpleDraweeView.setImageURI(item.getImgsrc());

        TextView distance = customViewHold.getView(R.id.distance);
        distance.setText(item.getDistance());

        TextView follow = customViewHold.getView(R.id.follow);
        follow.setText("粉丝  " + item.getFollow_num());

        TextView guanzhu = customViewHold.getView(R.id.guanzhu);
        guanzhu.setText("关注  " + item.getFuns_num());

        ImageView sex = customViewHold.getView(R.id.sex);

        if ("male".equals(item.getSex_flag())) {
            sex.setImageResource(R.mipmap.ic_nan);
        } else {
            sex.setImageResource(R.mipmap.ic_nv);
        }

        TextView name = customViewHold.getView(R.id.name);
        name.setText(item.getNick_name());


        customViewHold.getRoorView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                RongIM.getInstance().startPrivateChat(mContext, item.getUser_id(), item.getNick_name());
            }
        });


    }
}
